package wiki.generic.iotests;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import wiki.generic.io.Element;
import wiki.generic.io.ElementsMapWriter;

/**
 * 
 * @author <p><strong>JwTeam</strong></p> 
 *
 */
public class ConcreteElementsMapWriter implements ElementsMapWriter{

	@Override
	public void writeElementsMap(HashMap<Integer, Element> map,
			String destination) {
		File f=new File(destination);
		try {
			BufferedWriter out=new BufferedWriter(new FileWriter(f));
			Set<Integer> keys=map.keySet();
			for (Iterator<Integer> iterator = keys.iterator(); iterator.hasNext();) {
				Integer ID = iterator.next();
				out.write(ID+"$$||$$"+map.get(ID).getInfo()+"$$||$$"+map.get(ID).getOwner()+"\n");
			}
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}
}
